package com.xayy.health.mgt.model;

import cn.kawins.mybatis.base.BaseModel;
import lombok.*;
import lombok.extern.slf4j.Slf4j;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @author houchengwei
 * 遥测数据
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "HEALTH.tb_telemetry_data")
@EqualsAndHashCode(callSuper = true)
@Slf4j
public class TelemetryData extends BaseModel<String> {

    @Id
    private String id;
    @Column(name = "sate_code")
    private String sateCode;

    @Column(name = "param_code")
    private String paramCode;

    @Column(name = "value_type")
    private String valueType;

    @Column(name = "value")
    private String value;

    @Column(name = "time")
    private String time;

    @Transient
    private Long parentTaskId;

    @Transient
    private Long taskId;


    public Double getDoubleValue(){
        try{
            Double.valueOf(value);
        }catch (Exception e){
//            return 0D;
            log.error("此时间值异常，time={},value={}",time,value);
            return null;
        }
        return Double.valueOf(value);

    }

    @Override
    public String idValue() {
        return id;
    }

}
